﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cinser.Common.Silverlight.DT
{
    /*
     * 定义列，保存表的结构
     * */
    public class DMPDataColumn
    {

        //构造
        public DMPDataColumn()
        {
            this.columnName = "";
            this.dataType = null;
            this.defaultValue = System.DBNull.Value;
        }
        public DMPDataColumn(string name, Type type)
        {
            if (name==null||type==null)
            {
                throw new InvalidOperationException("value is null");
            }
            this.columnName = name;
            this.dataType = type;
            this.defaultValue = System.DBNull.Value;
        }

        #region  方法
        /// <summary>
        /// 判断obj是否和该对象一样，列名一样则判为一样
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>一样返回TRUE，否则返回FALSE</returns>
        public override bool Equals(object obj)
        {
            DMPDataColumn column = obj as DMPDataColumn;
            if (column.ColumnName==this.ColumnName)
            {
                return true;
            }
            return false;
        }






        /// <summary>
        /// 设置相关量的表
        /// </summary>
        /// <param name="table"></param>
        internal void SetTable(DMPDataTable table)
        {
            this.table = table;
        }
        #endregion





        #region  属性
        //columnName
        private string columnName;
        public string ColumnName
        {
            get { return columnName; }
            set { columnName = value; }
        }

        //DataType 
        private Type dataType;
        public Type DataType
        {
            get { return dataType; }
            set { dataType = value; }
        }

        //Table 
        private DMPDataTable table=null;
        public DMPDataTable Table
        {
            get
            {
                return table;
            }
        }


        //DefaultValue
        private object defaultValue;
        public object DefaultValue
        {
            get
            {
                return defaultValue;
            }
            set
            {
                defaultValue = value;
            }
        }

        #endregion






    }
}
